<%@ page import="java.util.List" %>
<%@ page import="entity.Orgnazition" %>
<%@ page import="service.OrgnazitionService" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/8/9
  Time: 12:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>

<head>
    <title>Title</title>
    <style>
        /*设置奇数行颜色*/
        table tr:nth-child(odd)
        {
            background: rgb(178, 178, 179);
        }
        /*设置偶数行颜色*/
        table tr:nth-child(even)
        {
            background: rgb(241, 241, 241);
        }
        /*设置鼠标聚焦到行上是凸显*/
        table tr:hover{
            background-color: rgb(121, 121, 121);
        }
        div {
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
    <base href="${pageContext.request.contextPath}/">
    <script src="js/jQuery3.6.0.js"></script>
</head>
<body>

        <div>
            <h1>添加组织机构</h1>
            <a href="main/demo2.jsp">办卡</a>
        </div>
        <div>
            <table >

                <tr>
                    <td>组织机构名称</td>
                    <td>负责人</td>
                    <td>业务状态</td>
                    <td>创建日期</td>
                    <td>操作</td>
                </tr>
                <c:forEach var="card" items="${requestScope.list}">
                <tr>
                    <td>${card.name}</td>
                    <td>${card.principalName}</td>
                    <c:if test="${card.status==0}">
                        <td>开启业务</td>
                    </c:if>
                    <c:if test="${card.status==1}">
                        <td>暂停业务</td>
                    </c:if>
                    <td>${card.createDate}</td>
                    <c:if test="${card.status==1}">
                        <td><a href="javascript:void(null)" onclick="status('开启业务',${card.id},${card.status})">开启业务</a></td>
                    </c:if>
                    <c:if test="${card.status==0}">
                        <td><a href="javascript:void(null)" onclick="status('暂停业务',${card.id},${card.status})">暂停业务</a></td>
                    </c:if>
                </tr>
                </c:forEach>
            </table>
            <sapn id="sapn1"></sapn>
        </div>
</body>
<script>

    function status(e,id,status){
        let a;
        if (e=='暂停业务'){
            a=confirm("确定要暂停业务？")
        }
        if (e=="开启业务"){
            location.href="${pageContext.request.contextPath}/OrgnazitionStatus?id="+id+"&status="+status ;
        }
        if (a){
            location.href="${pageContext.request.contextPath}/OrgnazitionStatus?id="+id+"&status="+status ;
        }
    }
</script>
</html>
